package com.frkj.yuan.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.frkj.yuan.R;
import com.frkj.yuan.adapter.BaseRecyclerHolder;
import com.frkj.yuan.adapter.BaseRecyclerRefreshAdapter;
import com.frkj.yuan.base.BaseActivity;
import com.frkj.yuan.data.YuyueKeshiDataUtils;
import com.frkj.yuan.entity.AddCardBean;
import com.frkj.yuan.utils.FullScreenUtils;
import com.frkj.yuan.view.RecyclerViewLayoutManager;

import java.io.IOException;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import cn.ycbjie.ycstatusbarlib.bar.YCAppBar;

/**
 * 信息说明: 我的卡包
 * company: 兰州丰荣信息科技有限公司
 * 创建时间: on 2022/3/4 16 ：31
 * 项目名称：yuanban
 */
public class MyCardActivity extends BaseActivity implements BaseRecyclerRefreshAdapter.OnItemClickListener {
    @BindView(R.id.base_title)
    TextView mTitleMsg;
    @BindView(R.id.base_recycler)
    RecyclerView mRecylerViews;
    private BaseRecyclerRefreshAdapter<AddCardBean> mAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_card_view;
    }

    @Override
    public void initLayoutView() {
        mTitleMsg.setText("卡包");
        FullScreenUtils.getInstance().fullScreen(MyCardActivity.this,true);
        RecyclerViewLayoutManager.setLinearVerticalManager(MyCardActivity.this, mRecylerViews);
        List<AddCardBean> mLeftList = YuyueKeshiDataUtils.getCardList();
       mAdapter =  new BaseRecyclerRefreshAdapter<AddCardBean>(MyCardActivity.this, mLeftList, R.layout.card_item_view) {
            @Override
            public void convert(BaseRecyclerHolder holder, AddCardBean item, int position, boolean isScrolling) throws IOException {
                holder.setText(R.id.card_name, item.getCard());
                holder.setText(R.id.card_states,item.getmCardStates());
                RelativeLayout mCardBack = holder.getView(R.id.rele_card);
                ImageView iocnImage =  holder.getView(R.id.image_card);
                if (item.getStates()==0){
                    mCardBack.setBackgroundResource(R.drawable.zsyh_bg);
                    iocnImage.setBackgroundResource(R.drawable.gongshangyinhang);
                }else if (item.getStates()==1){
                    mCardBack.setBackgroundResource(R.drawable.jsyh_bg);
                    iocnImage.setBackgroundResource(R.drawable.jiansheyinhang);
                }
            }
        };
        mRecylerViews.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener(this);
    }
    @OnClick({R.id.base_back, R.id.add_card})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.base_back:
                finishWitchAnimation();
                break;
            case R.id.add_card:
                openActivityWitchAnimation(AddBlankCardActivity.class);
                break;
        }
    }

    @Override
    public void onItemClick(RecyclerView parent, View view, int position) {
        openActivityWitchAnimation(UnBindCardActivity.class);
    }
}
